{include file="header/index" /}
<div class="newContentBox">
    <div class="fixedFather">
        <div class="fix">
            推广升级
            <span class="newNotice"><span class="newtext">*</span>为必填项</span>
            <div class="newFixBtnBox">
                <button type="button" class="newBtnDefault newBtnGray" onclick="returnBack(this)"> <i
                        class="fa fa-mail-reply"></i>返回</button>
            </div>
        </div>
    </div>
    <form class="layui-form newListPart ">
        <div class="newPart">
            <div class="newTitle">
                <i class="fa fa-address-book allColor icon"></i> 主要信息
            </div>
        </div>
        <div class="newContent">
            <div class="layui-form-item cover_layui_f_i2">
                <label class="layui-form-label cover_layui_f_l"><span class="cover_new_label">*</span> 推广</label>
                <div class="layui-input-block cover_layui_i_b">
                    <select name="workers_id" required  lay-verify="required">
                        <option value="">请选择推广</option>
                        {foreach $workers as $k => $v}
                        <option value="{$v.workers_id}">{$v.workers_name}-{$v.workers_position}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item cover_layui_f_i2">
                <label class="layui-form-label cover_layui_f_l"><span class="cover_new_label">*</span> 升级职位</label>
                <div class="layui-input-block cover_layui_i_b">
                    <select name="position_id" required  lay-verify="required">
                        <option value="">请选择升级职位</option>
                        {foreach $workers_position as $k => $v}
                        <option value="{$k}">{$v}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item cover_layui_f_i2">
                <label class="layui-form-label cover_layui_f_l"><span class="cover_new_label">*</span>备注</label>
                <div class="layui-input-block cover_layui_i_b">
                            <textarea maxlength="500" name="remarks" placeholder="请输入备注" class="layui-textarea layui-input"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form-item ">
            <div class="layui-input-block cover_layui_i_b">
                <button class="layui-btn newBtnDefault newBtnPrimary" lay-submit lay-filter="formDemo">保存</button>
                <button type="reset" class="layui-btn newBtnDefault">重置</button>
            </div>
        </div>
    </form>
</div>


<script>
    var layer = layui.layer,
        element = layui.element,
        laydate = layui.laydate,
        laypage = layui.laypage,
        form = layui.form,
        upload = layui.upload,
        layedit = layui.layedit;
    form.render();
    //提交表单
    var flag = false;
    form.on('submit(formDemo)', function(data){
        if(flag){
            return false;
        }
        flag = true;
        var formData = data.field;
        if(formData.workers_id==''){
            parent.layer.msg('请选择推广',{icon:0,time:1000});
            return false;
        }
        if(formData.position_id==''){
            parent.layer.msg('请选择升级职位',{icon:0,time:1000});
            return false;
        }
        $.post("{:url('workers_upgrade')}",formData,function(e){
            if(e.code == 1){
                top.layer.msg(e.msg, {
                    icon: 1,
                    time: 2000
                },function(){
                    top.layer.close();
                    //history.go(-1);
                    window.location.href = "{:url('index')}";
                });
            }else{
                top.layer.msg(e.msg, {
                    icon: 0,
                    time: 2000
                });
            }
            flag = false;
        },'json');
        return false;
    });




</script>